import configparser
import json
from pathlib import Path

work_dir = 'E:/pythonstudy/magedu/project/temp'
ini_file = Path(work_dir,'mysql.ini')
json_file = Path(work_dir,'mysql.json')

cfg = configparser.ConfigParser()
cfg.read(ini_file)

d = {}
for i in cfg.sections():
    # print(i)
    # print(cfg.items(i))
    d[i] = dict(cfg.items(i))
# print(d)

with open(json_file,'w',encoding='UTF-8') as f:
    json.dump(d,f)


# 做得不错
